package cn.dkdoo.utils.config.transactionInfo;

import cn.dkdoo.utils.common.ThreadLocalAbstract;
import org.springframework.core.NamedThreadLocal;

/**
 * @author nicky
 * @date 2021/5/11 上午11:03
 */
public class TransactionInfoManager implements ThreadLocalAbstract<TransactionInfoAbstract> {
    private static final ThreadLocal<TransactionInfoAbstract> troNoLocal =
            new NamedThreadLocal<>("Current TransactionInfo");

    public TransactionInfoAbstract getCur() {
        return troNoLocal.get();
    }

    public void bindToThread(TransactionInfoAbstract troNo) {
        troNoLocal.set(troNo);
    }

    public void releaseToThread() {
        troNoLocal.remove();
    }
}
